<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('风控策略列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <input type="hidden" name="groupId" id="groupId" th:value="${groupId}" readonly/>
                <div class="select-list">
                    <ul>
                        <li>
                            <label>名称：</label>
                            <input type="text" name="elementsName"/>
                        </li>
                        <li>
                            <label>状态：</label>
                            <select name="sts" th:with="type=${@dict.getType('sys_sts')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var stsDatas = [[${@dict.getType('sys_sts')}]];
    var prefix = ctx + "rule/groupDetail";

    $(function () {
        var options = {
            url: ctx + "rule/items/getItemsList",
            modalName: "风控策略",
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            sidePagination: "client",
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: '编号',
                    visible: false
                },
                {
                    field: 'elementsName',
                    title: '名称'
                },
                {
                    field: 'sts',
                    title: '状态',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(stsDatas, value);
                    }
                },
                {
                    field: 'remark',
                    align: 'center',
                    title: '备注'
                }]
        };
        $.table.init(options);
    });

    /* 添加策略-选择策略-提交 */
    function submitHandler(index, layero) {
        var rows = $.table.selectFirstColumns();
        if (rows.length == 0) {
            $.modal.alertWarning("请至少选择一条记录");
            return;
        }
        var groupId = $("#groupId").val();
        var data = {
            "groupId": groupId,
            "itemsIds": rows.join()
        };
        $.operate.save(prefix + "/add", data);
    }
</script>
</body>
</html>